<template>
  <div>

    <!--引用表格-->
    <BasicTable @register="registerTable" :rowSelection="rowSelection">
      <!--插槽:table标题-->
      <template #tableTitle> </template>
      <!--字段回显插槽-->
      <template #bodyCell="{ column, record, index, text }"> </template>
      <!--操作栏-->
      <template #action="{ record }">
        <a-button type="text" @click="handleDetail(record)"> 详情</a-button>
      </template>
    </BasicTable>
    <!-- 表单区域 -->
    <AppUserGoldDetailModal @register="registerModal" @success="handleSuccess" />

    <!--字典配置抽屉-->
    <DictItemList @register="registerDrawer" />
  </div>
</template>
<script lang="ts" name="hd-appUserGoldDetail" setup>
  import { ref, reactive } from 'vue';
  import { BasicTable } from '/@/components/Table';
  import { useModal } from '/@/components/Modal';
  import { useListPage } from '/@/hooks/system/useListPage';
  import DictItemList from './components/DictItemList.vue';
  import { useDrawer } from '/@/components/Drawer';
  import AppUserGoldDetailModal from './components/AppUserGoldDetailModal.vue';
  import { childUserGoldTotalColumns, childsearchFormSchema } from './AppUserGoldDetail.data';
  import { queryChildUserGoldList, getChildUserGoldTotal } from './AppUserGoldDetail.api';
  const queryParam = reactive<any>({});
  const totalNum = ref(0);
  const totalClickCount = ref(0);
  //字典配置drawer
  const [registerDrawer, { openDrawer }] = useDrawer();
  //注册model
  const [registerModal] = useModal();
  //注册table数据
  const { tableContext } = useListPage({
    tableProps: {
      title: 'app_user_gold_detail_child',
      api: (params) => {
        getChildUserGoldTotal(params).then((res) => {
          console.log(res);
          totalNum.value = res.goldNum;
          totalClickCount.value = res.clickCount;
        });
        return queryChildUserGoldList(params);
      },
      columns: childUserGoldTotalColumns,
      canResize: false,
      formConfig: {
        //labelWidth: 120,
        schemas: childsearchFormSchema,
      },
      actionColumn: {
        width: 120,
        fixed: 'right',
      },
      showActionColumn: false,
      showIndexColumn: true,
      beforeFetch: (params) => {
        return Object.assign(params, queryParam);
      },
    },
  });
  const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
  /**
   * 查看详情
   */
  function handleDetail(record) {
    console.log(queryParam);
    // openDrawer(true, {
    //   userId: record.userId,
    //   day: queryParam.day,
    // });
  }
  /**
   * 成功回调
   */
  function handleSuccess() {
    (selectedRowKeys.value = []) && reload();
  }
</script>

<style lang="less" scoped>
  :deep(.ant-picker),
  :deep(.ant-input-number) {
    width: 100%;
  }
</style>
